/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boundless.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author hendrikdekock
 */
@Entity
@Table(name = "TRADEREQUESTS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Traderequests.findAll", query = "SELECT t FROM Traderequests t"),
    @NamedQuery(name = "Traderequests.findByStatus", query = "SELECT t FROM Traderequests t WHERE t.status = :status"),
    @NamedQuery(name = "Traderequests.findByTradeid", query = "SELECT t FROM Traderequests t WHERE t.tradeid = :tradeid")})
public class Traderequests implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @NotNull
    @Column(name = "STATUS")
    private short status;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "TRADEID")
    private Integer tradeid;
    @JoinColumn(name = "OFFEREDPLAYERID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Player offeredplayerid;
    @JoinColumn(name = "DEMANDEDPLAYERID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Player demandedplayerid;
    @JoinColumn(name = "SENDERTEAMID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Fantasyteams senderteamid;
    @JoinColumn(name = "RECEIVERTEAMID", referencedColumnName = "ID")
    @ManyToOne(optional = false)
    private Fantasyteams receiverteamid;

    public Traderequests() {
    }

    public Traderequests(Integer tradeid) {
        this.tradeid = tradeid;
    }

    public Traderequests(Integer tradeid, short status) {
        this.tradeid = tradeid;
        this.status = status;
    }
    
    public Traderequests(Integer tradeid, Player off, Player dem, Fantasyteams send, Fantasyteams rec) {
        this.tradeid = tradeid;
        this.offeredplayerid = off;
        this.demandedplayerid = dem;
        this.senderteamid  = send;
        this.receiverteamid = rec;
        this.status = 0;
    }

    public short getStatus() {
        return status;
    }

    public void setStatus(short status) {
        this.status = status;
    }

    public Integer getTradeid() {
        return tradeid;
    }

    public void setTradeid(Integer tradeid) {
        this.tradeid = tradeid;
    }

    public Player getOfferedplayerid() {
        return offeredplayerid;
    }

    public void setOfferedplayerid(Player offeredplayerid) {
        this.offeredplayerid = offeredplayerid;
    }

    public Player getDemandedplayerid() {
        return demandedplayerid;
    }

    public void setDemandedplayerid(Player demandedplayerid) {
        this.demandedplayerid = demandedplayerid;
    }

    public Fantasyteams getSenderteamid() {
        return senderteamid;
    }

    public void setSenderteamid(Fantasyteams senderteamid) {
        this.senderteamid = senderteamid;
    }

    public Fantasyteams getReceiverteamid() {
        return receiverteamid;
    }

    public void setReceiverteamid(Fantasyteams receiverteamid) {
        this.receiverteamid = receiverteamid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tradeid != null ? tradeid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Traderequests)) {
            return false;
        }
        Traderequests other = (Traderequests) object;
        if ((this.tradeid == null && other.tradeid != null) || (this.tradeid != null && !this.tradeid.equals(other.tradeid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "boundless.entities.Traderequests[ tradeid=" + tradeid + " ]";
    }
    
}
